define(["../common"], function() {
	
	
	var $form = $("#step_0");
	var formCfg = {
		fields: {
			oldPwd: "原密码:required;password;remote[" + g_userDomain + "/member/checkPwd/json]",
			newPwd: "新密码:required;password",
			"#pwd2": "确认密码:required;match(newPwd)"
		}
	};
	
	requirePlugin(["validator"],function() {
		$form.validator(formCfg);
	});
	
	// 提交完成表单
	$form.on('valid.form', function(e, form) {
		if (!$form.lock()) return;
		
		$form.loadMsg("正在提交...");
		$.post(g_userDomain + "/member/pwdDo/json", $form.serialize(), function(data){
			if (data.status !== 0) {
				$form.failMsg(data.message);
				return;
			}
			$form.infoMsg("修改成功");
			
			$("[id^=step_]").hide();
			$("#step_1").show();
		});
		
	});
	
	// 完成
	$("#btn_submit").click(function() {
		$form.trigger('validate');
		return false;
	});	
	
});